﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using hessiancsharp.client;

    class Validate
    {
        public interface ValidateInterface
        {
            bool isCustomerExpiredByCode(string code);
            bool isCustomerExpiredByCodeAndIp(string code, string ip);
        }

        private CHessianProxyFactory factory = new CHessianProxyFactory();
        private string url = "";
        private string code;
        private string ip;
        private ValidateInterface handler = null;

        public Validate(string url, string code, string ip){
            this.url = url;
            this.code = code;
            this.ip = ip;
        }

        public bool init(){
            try
            {
                handler = (ValidateInterface)factory.Create(typeof(ValidateInterface), url);
                return true;
            }catch(Exception){
                
            }
            return false;
        }

        public bool validateByCode()
        {
            return handler.isCustomerExpiredByCode(code);
        }

        
        public bool validateByCodeAndIp()
        {
            return handler.isCustomerExpiredByCodeAndIp(code, ip);
        }
    }

